class Solution(object):
    def isOneBitCharacter(self, bits):
        """
        :type bits: List[int]
        :rtype: bool
        """
        n = len(bits)
        if n == 1:
            return True
        if n == 2:
            return bits[0] == 0
        DP = [0] * (n - 1)
        for i in range(n - 1):
            if i == 0:
                DP[i] = 1 - bits[i]
            if i == 1:
                if not bits[i] or (bits[i - 1] and bits[i]):
                    DP[i] = 1
            if i >= 2:
                if not bits[i] or (DP[i - 2] and bits[i - 1] and bits[i]):
                    DP[i] = 1
        if bits[-2] == 0:
            return True
        else:
            if not DP[-2]:
                return True
            else:
                return False



